#!/bin/bash
#pMusic - frontend
#GPL - Copyright Sigmund Berglund

export TEXTDOMAIN=pmusic
export OUTPUT_CHARSET=UTF-8

#override main pMusic settings
gettext 'Search' > $WORKDIR/filebrowser_dir
echo "pMusic - $(gettext 'Podcast manager')" > $WORKDIR/window_title

#override settings in pmusicrc to search only radio stations
export SEARCH_MYMUSIC=false
export SEARCH_COLLECTIONS=false
export SEARCH_RADIO=false
export SEARCH_PODCAST=true
export SEARCH_ALBUMART=false
export SEARCH_YOUTUBE=false
export SEARCH_JAMENDO=false
export SEARCH_FILES=false
#Sourcelist columns
export COLUMN_ARTIST=true
export COLUMN_TITLE=true
export COLUMN_ALBUM=false
export COLUMN_NR=false
export COLUMN_YEAR=true
export COLUMN_GENRE=true
export COLUMN_COMMENT=false
export COLUMN_RATING=false
export COLUMN_FORMAT=false
export COLUMN_BITRATE=false
export COLUMN_LENGTH=true
export COLUMN_TEMPO=false
export COLUMN_PATH=true

. $APPDIR/gui_add
. $APPDIR/gui_playlist #svg nowplaying
. $APPDIR/gui_misc -skip_albumart
. $APPDIR/gui_navigation
. $APPDIR/gui_mixer

$APPDIR/func_podcast -show_podcast
echo '(00:00)' > $WORKDIR/statusbar_playlist #this holds total time of all added tracks to playqueue
echo false > $WORKDIR/UPDATE_GUI

#read geometry
. $HOME/.pmusic/pmusicrc.Podcast

GUI='
<window title="'$(<$WORKDIR/window_title)'" icon-name="pmusic" default_height="'$WINDOW_HEIGHT'" default_width="'$WINDOW_WIDTH'">
<vbox '$ST'>
  <vbox '$SF'>
    <hbox '$SF'>
      '"`grep -B1 -A100 -F 'HISTORY_UNDO' <<< "$GUI_ADD_SEARCH" | grep -B100 -Fm1 '</entry>'`"'
      <button tooltip-text="'$(gettext 'Add timestamp to podcast to keep track of it for next time')'">
        <input file>'$APPDIR'/themes/'$THEME'/icon_timestamp.svg</input>
        <label>'$(gettext 'Timestamp')'</label>
        <height>22</height>
        <action>'$APPDIR'/func_favorites -add_favorites_with_timestamp</action>
      </button>
      <button>
        <input file>'$APPDIR'/themes/'$THEME'/icon_podcast_channel.svg</input>
        <label>'$(gettext 'Browse')'</label>
        <height>22</height>
        <action>'$APPDIR'/func_podcast -show_podcast</action>
        <action>refresh:SOURCE</action>
      </button>
    </hbox>
  </vbox>
  <vbox '$ST'>
    '$GUI_ADD_LIST'
  </vbox>
  <vbox '$SF'>
    <hbox '$ST'>
      <hbox '$ST'>
        '$GUI_SVG_NOWPLAYING'
      </hbox>
      <vbox '$SF'>
        <hbox '$SF'>
          <button>
            <input file>'$APPDIR'/themes/'$THEME'/icon_play.svg</input>
            <height>22</height>
            <action>'$APPDIR'/func_player -stop; '$APPDIR'/func_player -play</action>
          </button>
          <button>
            <input file>'$APPDIR'/themes/'$THEME'/icon_stop.svg</input>
            <height>22</height>
            <action>'$APPDIR'/func_player -stop</action>
          </button>
          <button><input file stock="gtk-preferences"></input><action>'$APPDIR'/func_config -podcast</action></button>
        </hbox>
        <hbox height-request="16" '$ST'>
          <text width-request="12" '$SF'><label>""</label></text>
          <pixmap '$SF'>
            <input file>'$APPDIR'/themes/'$THEME'/volume.svg</input>
            <height>14</height>
          </pixmap>
          '$GUI_VOLUME'
        </hbox>
      </vbox>
    </hbox>
  </vbox>
    '$GUI_PROGRESSBAR'
   <vbox visible="false" '$SF'>
     '$GUI_PROGRESS'
   </vbox>
  <vbox '$SF'>
    '$GUI_STATUSBAR'
  </vbox>
</vbox>
<action signal="show">'$APPDIR'/func_mixer -get_levels</action>
<action signal="show">refresh:VOLUME</action>
<action signal="show">echo > '$WORKDIR'/gui_is_running</action>
<action signal="delete-event">'$APPDIR'/func_config -write_frontend_geometry "'$OVERRIDE_PMUSIC_FRONTEND'"</action>
<action signal="delete-event">'$APPDIR'/func -quit</action>
<action signal="delete-event">exit:Exit</action>
</window>'
